home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / TRADSTDC.H < prev    next >
C/C++ Source or Header  |  1993-03-16  |  4KB  |  144 lines

  1. /*    SCCS Id: @(#)tradstdc.h    3.0    89/07/12
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #ifndef TRADSTDC_H
  6. #define    TRADSTDC_H
  7.  
  8. #ifdef DUMB
  9. #undef void
  10. #define void    int
  11. #endif
  12.  
  13. #ifdef APOLLO    /* the Apollo C compiler claims to be __STDC__, but isn't */
  14. #undef __STDC__
  15. #endif
  16.  
  17. /*
  18.  * ANSI X3J11 detection.
  19.  * Makes substitutes for compatibility with the old C standard.
  20.  */
  21.  
  22. /* Decide how to handle variable parameter lists:
  23.  * USE_STDARG means use the ANSI <stdarg.h> facilities (only ANSI compilers
  24.  * should do this, and only if the library supports it).
  25.  * USE_VARARGS means use the <varargs.h> facilities.  Again, this should only
  26.  * be done if the library supports it.  ANSI is *not* required for this.
  27.  * Otherwise, the kludgy old methods are used.
  28.  * The defaults are USE_STDARG for ANSI compilers, and USE_OLDARGS for
  29.  * others.
  30.  */
  31.  
  32. /* #define USE_VARARGS        /* use <varargs.h> instead of <stdarg.h> */
  33. /* #define USE_OLDARGS        /* don't use any variable argument facilites */
  34.  
  35. #ifdef __STDC__
  36. # if defined(__GNUC__) && defined(VMS)
  37. #   define USE_OLDARGS          /* <stdarg.h> is missing for some versions */
  38. # endif
  39. # if !defined(USE_VARARGS) && !defined(USE_OLDARGS)
  40. #   define USE_STDARG
  41. # endif
  42. #endif
  43.  
  44. #ifdef NEED_VARARGS        /* only define these if necessary */
  45. #ifdef USE_STDARG
  46. # include <stdarg.h>
  47. # define VA_DECL(typ1,var1)    (typ1 var1, ...) { va_list the_args;
  48. # define VA_DECL2(typ1,var1,typ2,var2)    \
  49.     (typ1 var1, typ2 var2, ...) { va_list the_args;
  50. # define VA_INIT(var1,typ1)
  51. # define VA_NEXT(var1,typ1)    var1 = va_arg(the_args, typ1)
  52. # define VA_ARGS        the_args
  53. # define VA_START(x)        va_start(the_args, x)
  54. # define VA_END()        va_end(the_args)
  55. #else
  56. # ifdef USE_VARARGS
  57. #  include <varargs.h>
  58. #  define VA_DECL(typ1,var1)    (va_alist) va_dcl {\
  59.         va_list the_args; typ1 var1;
  60. #  define VA_DECL2(typ1,var1,typ2,var2)    (va_alist) va_dcl {\
  61.         va_list the_args; typ1 var1; typ2 var2;
  62. #  define VA_ARGS        the_args
  63. #  define VA_START(x)        va_start(the_args)
  64. #  define VA_INIT(var1,typ1)     var1 = va_arg(the_args, typ1)
  65. #  define VA_NEXT(var1,typ1)    var1 = va_arg(the_args,typ1)
  66. #  define VA_END()        va_end(the_args)
  67. # else
  68. #   define VA_ARGS    arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9
  69. #   define VA_DECL(typ1,var1)  (var1,VA_ARGS) typ1 var1; \
  70.     char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; {
  71. #   define VA_DECL2(typ1,var1,typ2,var2)  (var1,var2,VA_ARGS) \
  72.     typ1 var1; typ2 var2;\
  73.     char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; {
  74. #   define VA_START(x)
  75. #   define VA_INIT(var1,typ1)
  76. #   define VA_END()
  77. # endif
  78. #endif
  79. #endif /* NEED_VARARGS */
  80.  
  81.  
  82. /* Unfortunately amiga aztec 5.0 doesn't handle prototyping chars correctly */
  83. #if (defined(__STDC__) && !defined(AZTEC_50)) || defined(MSDOS) || defined(THINKC4)
  84.  
  85. /* Used for robust ANSI parameter forward declarations:
  86.  * int VDECL(sprintf, (char *, const char *, ...));
  87.  *
  88.  * NDECL() is used for functions with zero arguments;
  89.  * FDECL() is used for functions with a fixed number of arguments;
  90.  * VDECL() is used for functions with a variable number of arguments.
  91.  * Separate macros are needed because ANSI will mix old-style declarations
  92.  * with prototypes, except in the case of varargs, and the OVERLAY-specific
  93.  * trampoli.* mechanism conflicts with the ANSI <<f(void)>> syntax.
  94.  */
  95.  
  96. # define NDECL(f)    f(void)    /* Must be overridden if OVERLAY set later */
  97.  
  98. # define FDECL(f,p)    f p
  99.  
  100. # if defined(MSDOS) || defined(USE_STDARG)
  101. #  define VDECL(f,p)    f p
  102. # else
  103. #  define VDECL(f,p)    f()
  104. # endif
  105.  
  106. # ifdef __TURBOC__    /* Cover for stupid Turbo C */
  107. #  define genericptr_t    void *
  108. # else
  109. typedef void *        genericptr_t;
  110. #  ifndef __STDC__
  111. #   define const
  112. #   define signed
  113. #   define volatile
  114. #  endif
  115. # endif
  116.  
  117. #else /* __STDC__ */    /* a "traditional" C  compiler */
  118.  
  119. # define NDECL(f)    f()
  120. # define FDECL(f,p)    f()
  121. # define VDECL(f,p)    f()
  122.  
  123. # ifndef genericptr_t
  124. #  if defined(AMIGA) || defined(HPUX)
  125. typedef void *        genericptr_t;
  126. #  else
  127. typedef char *        genericptr_t;
  128. #  endif
  129. # endif
  130.  
  131. #ifndef AZTEC_50    /* Take out when aztec handles prototyping OK */
  132. # define const
  133. # define signed
  134. # define volatile
  135. #endif
  136.  
  137. #endif /* __STDC__ */
  138.  
  139. #ifdef __HC__    /* MetaWare High-C defaults to unsigned chars */
  140. # undef signed
  141. #endif
  142.  
  143. #endif /* TRADSTDC_H /**/
  144.